package com.csf.entity;

public class Page {
    //当前页面
    private int current=1;
    //每页显示的数据
    private int limit=10;
    //页面跳转的路径
    private String path;
    //总条数
    private int rows;

    public int getCurrent() {
        return current;
    }

    public void setCurrent(int current) {
        if (current>0){
            this.current = current;
        }

    }

    public int getLimit() {
        return limit;
    }

    public void setLimit(int limit) {
        if (limit>1 && limit <1000){
            this.limit = limit;
        }

    }

    public String getPath() {
        return path;
    }

    public void setPath(String path) {
        this.path = path;
    }

    public int getRows() {
        return rows;
    }

    public void setRows(int rows) {
        if (rows >= 0) {
            this.rows = rows;
        }
    }

    //获取总页数
    public int getTotal(){
        if (rows % limit == 0){
            return rows/limit;
        }else {
            return  rows/limit+1;
        }
    }
    //当前页的起始行数
    public int getiniRows(){
        return current*limit-limit;
    }

    //获得起始页码
    public int getInits(){
        int initpage = current-2;
        return initpage<1?1:initpage;
    }
    //获得终止页码
    public int getFinals(){
        int finals = current+2;
        return finals>getTotal()?getTotal():finals;
    }
}
